package cn.cboard.dao.sql;

import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import cn.cboard.dao.UserDao;
import cn.cboard.database.Query;
import cn.cboard.model.User;

@SuppressWarnings("unchecked")
public class UserDaoSql implements UserDao{
	private final static Logger logger=Logger.getLogger(UserDaoSql.class);
	private Query query;
	public UserDaoSql(Query query) {
		this.query = query;
	}

	public void create(User user) {
		
	}

	
	public User getUser(Long userId) {
		String sqlquery = "select * from forumusers where userid=?";
		List queryParams = new ArrayList();
		queryParams.add(userId);		
		User u = (User) query.queryMapper(queryParams, sqlquery, new UserMapper());
		return u;
	}

	public User getUserByName(String username,String password) {
		logger.debug("[boardmx]--> getUserByName: " + username);
		String sqlquery = "select * from forumusers where username=? and password=?";
		List queryParams = new ArrayList();
		queryParams.add(username);
		queryParams.add(password);
		User u = (User) query.queryMapper(queryParams, sqlquery, new UserMapper());
		return u;
	}

	public List<User> listUser(int start, int count) {

		return null;
	}

	public void removeUser(User user) {

		
	}

	public void updateUser(User user) {

		
	}

}
